using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif

/// <summary>
/// 本地化语言类型枚举
/// </summary>
public enum LocalizationTypeDef
{
    /// <summary>简体中文</summary>
    zhCN = 0,
    /// <summary>繁体中文</summary>
    zhTW = 1,
    /// <summary>英语（美国）</summary>
    enUS = 2,
    /// <summary>德语</summary>
    deDE = 3,
    /// <summary>日语</summary>
    jaJP = 4,
    /// <summary>韩语</summary>
    koKR = 5,
    /// <summary>法语</summary>
    frFR = 6,
    /// <summary>西班牙语</summary>
    esES = 7,
    /// <summary>葡萄牙语</summary>
    ptPT = 8,
    /// <summary>俄语</summary>
    ruRU = 9,
    /// <summary>土耳其语</summary>
    trTR = 10,
    /// <summary>越南语</summary>
    viVN = 11,
    /// <summary>阿拉伯语</summary>
    arSA = 12,
    /// <summary>泰语</summary>
    thTH = 13,
    /// <summary>印尼语</summary>
    idID = 14,
}


public class UXGUIConfig : ScriptableObject
{
    /// <summary>UXTools资源根目录路径</summary>
    public static readonly string RootPath = "Assets/UXTools/Res/";
    /// <summary>UX-GUI资源目录路径</summary>
    public static readonly string GUIPath = RootPath + "UX-GUI/";

    /// <summary>UXImage组件默认材质路径</summary>
    public static readonly string UXImageDefaultMatPath = GUIPath + "Resources/Materials/UXImage.mat";
    /// <summary>UXText组件默认材质路径</summary>
    public static readonly string UXTextDefaultMatPath = GUIPath + "Resources/Materials/UXImage.mat";
    /// <summary>需要替换的精灵图片路径</summary>
    public static readonly string UXGUINeedReplaceSpritePathReplace = GUIPath + "Resources/Materials/need_replace.png";

    /// <summary>泰语词典文件路径</summary>
    public static readonly string ThaiWordDictPath = GUIPath + "Resources/thai_dict";

    /// <summary>UI新手引导资源路径</summary>
    public static readonly string UIBeginnerGuideResPath = "Assets/Res/UI/Prefab/BeginnerGuide/";

    // Localization
    /// <summary>是否启用本地化功能</summary>
    public static bool enableLocalization = false;
    /// <summary>当前本地化语言类型</summary>
    public static LocalizationTypeDef CurLocalizationType = LocalizationTypeDef.zhCN;
    // UIStateAnimator
    /// <summary>是否启用UI状态动画器优化</summary>
    public static bool EnableOptimizeUIStateAnimator = true;

    [SerializeField]
    /// <summary>支持的语言ID列表</summary>
    private List<int> m_AvailableLanguages;
    /// <summary>支持的语言ID列表</summary>
    public static List<int> availableLanguages
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_AvailableLanguages;
        }
    }

    #region 本地化配置

    #region Aot

    [SerializeField]
    /// <summary>本地化资源文件的文件夹路径 - 非热更</summary>
    private string m_LocalizationFolder_AOT;
    /// <summary>本地化资源文件的文件夹路径 - 非热更</summary>
    public static string LocalizationFolder_AOT
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_LocalizationFolder_AOT;
        }
#if UNITY_EDITOR
        set
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            uxConfig.m_LocalizationFolder_AOT = value;
            EditorUtility.SetDirty(uxConfig);
            AssetDatabase.SaveAssets();
        }
#endif
    }
    [SerializeField]
    /// <summary>本地化预览表格文件的路径 - 非热更</summary>
    private string m_PreviewTablePath_AOT;
    /// <summary>本地化预览表格文件的路径 - 非热更</summary>
    public static string PreviewTablePath_AOT
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_PreviewTablePath_AOT;
        }
#if UNITY_EDITOR
        set
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            uxConfig.m_PreviewTablePath_AOT = value;
            EditorUtility.SetDirty(uxConfig);
            AssetDatabase.SaveAssets();
        }
#endif
    }

    [SerializeField]
    /// <summary>本地化运行时表格文件的路径 - 非热更</summary>
    private string m_RuntimeTablePath_AOT;
    /// <summary>本地化运行时表格文件的路径 - 非热更</summary>
    public static string RuntimeTablePath_AOT
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_RuntimeTablePath_AOT;
        }
#if UNITY_EDITOR
        set
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            uxConfig.m_RuntimeTablePath_AOT = value;
            EditorUtility.SetDirty(uxConfig);
            AssetDatabase.SaveAssets();
        }
#endif
    }

    /// <summary>文本本地化JSON文件路径 - 非热更</summary>
    public static string TextLocalizationJsonPath_AOT
    {
        get
        {
            return UXGUIConfig.LocalizationFolder_AOT + "TextLocalization_AOT.json";
        }
    }

    #endregion


    #region Hot

    [SerializeField]
    /// <summary>本地化资源文件的文件夹路径 - 热更</summary>
    private string m_LocalizationFolder_HOT;
    /// <summary>本地化资源文件的文件夹路径 - 热更</summary>
    public static string LocalizationFolder_HOT
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_LocalizationFolder_HOT;
        }
#if UNITY_EDITOR
        set
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            uxConfig.m_LocalizationFolder_HOT = value;
            EditorUtility.SetDirty(uxConfig);
            AssetDatabase.SaveAssets();
        }
#endif
    }
    [SerializeField]
    /// <summary>本地化预览表格文件的路径 - 热更</summary>
    private string m_PreviewTablePath_HOT;
    /// <summary>本地化预览表格文件的路径 - 热更</summary>
    public static string PreviewTablePath_HOT
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_PreviewTablePath_HOT;
        }
#if UNITY_EDITOR
        set
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            uxConfig.m_PreviewTablePath_HOT = value;
            EditorUtility.SetDirty(uxConfig);
            AssetDatabase.SaveAssets();
        }
#endif
    }

    [SerializeField]
    /// <summary>本地化运行时表格文件的路径 - 热更</summary>
    private string m_RuntimeTablePath_HOT;
    /// <summary>本地化运行时表格文件的路径 - 热更</summary>
    public static string RuntimeTablePath_HOT
    {
        get
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            return uxConfig.m_RuntimeTablePath_HOT;
        }
#if UNITY_EDITOR
        set
        {
            var uxConfig = ResourceManager.Load<UXGUIConfig>("UXGUIConfig");
            uxConfig.m_RuntimeTablePath_HOT = value;
            EditorUtility.SetDirty(uxConfig);
            AssetDatabase.SaveAssets();
        }
#endif
    }

    /// <summary>文本本地化JSON文件路径 - 热更</summary>
    public static string TextLocalizationJsonPath_HOT
    {
        get
        {
            return UXGUIConfig.LocalizationFolder_HOT + "TextLocalization_HOT.json";
        }
    }

    #endregion


    #endregion

}